package fun.anin.aninhongbao.controller;

import fun.anin.aninhongbao.entity.RedPacketRecord;
import fun.anin.aninhongbao.result.R;
import fun.anin.aninhongbao.sender.RabbitMQUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/***
 *
 * @author anin
 * @date: 2020/4/2 14:19
 * @version : V1.0
 */
@RestController
@RequestMapping("/record")
public class RedPacketRecordConroller {

    @Autowired
    private RabbitMQUtil rabbitMQUtil;

    /**
     * 通过mq记录
     * @return
     */
    @PostMapping("add")
    public R add(){
        RedPacketRecord record = RedPacketRecord.builder()
                .amount(18)
                .isLuck(1)
                .redPacketId(1L)
                .build();
        rabbitMQUtil.send("redpacket.RecordExchange","redpacket.record",record);
        return R.ok();
    }
}
